package com.baizhi.abstractx2;

import java.util.Scanner;

/**
 * 长方形
 */
public class Rectangle extends Shape {
    private double width; //宽
    private double height; //高



    @Override
    public double area() {
        return width * height;
    }

    @Override
    public double perimeter() {
        return (width + height) * 2;
    }

    @Override
    public void inInfo(Scanner scan) {
        System.out.println("请输入长方形的宽");
        width = scan.nextDouble();
        System.out.println("请输入长方形的高：");
        height = scan.nextDouble();

        //打印图形的面积和周长
        System.out.println("您输入的长方形的面积是：" + area());
        System.out.println("您输入的长方形的周长是：" + perimeter());
    }
}
